﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Resources/Master.Master" AutoEventWireup="true" CodeBehind="UpdateUser.aspx.cs" Inherits="Assignment_3.Feature___Users.UpdateUser" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript" lang="javascript ">
        function validateAndConfirm(message) {
            var validated = Page_ClientValidate('groupUpdate');

            if (validated) {
                return confirm(message);
            }
        }
    </script>

    <div style="margin-top: 20px; margin-left: 3%; margin-right: 3%">

        <h1>Users - Update User</h1>

        <div id="UserAccount">
            <asp:Label ID="lblUsername" runat="server" Text="Username:"></asp:Label>
            <br />
            <asp:TextBox ID="tbxUsername" runat="server" ReadOnly="True"></asp:TextBox>

            <br />
            <br />
            <asp:Label ID="lblCurrentPassword" runat="server" Text="Current Password:"></asp:Label>
            <br />
            <asp:TextBox ID="tbxCurrentPassword" runat="server" AutoPostBack="True" OnTextChanged="tbxCurrentPassword_TextChanged"></asp:TextBox>&nbsp;
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                ErrorMessage="Current Password Required    "
                ControlToValidate="tbxCurrentPassword"
                Display="Dynamic" ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RequiredFieldValidator>
            <asp:CustomValidator ID="CustomValidator1" runat="server"
                ErrorMessage="Current password incorrect    "
                ControlToValidate="tbxCurrentPassword"
                OnServerValidate="CustomValidator1_ServerValidate"
                Display="Dynamic"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:CustomValidator>

            <br />
            <br />
            <asp:Label ID="lblPassword" runat="server" Text="Password:"></asp:Label>
            <br />
            <asp:TextBox ID="tbxPassword" runat="server" TextMode="Password"></asp:TextBox>&nbsp;
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                ErrorMessage="Password Required    "
                ControlToValidate="tbxPassword"
                Display="Dynamic"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                ErrorMessage="Password must contain at least a number    "
                Display="Dynamic"
                ControlToValidate="tbxPassword"
                ValidationExpression="(^([\d][\w]*)$)|(^([\w]*[\d][\w]*)$)|(^([\w]*[\d])$)"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RegularExpressionValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
                ErrorMessage="Password must be at least 7 alphanumeric long and no spaces    "
                Display="Dynamic"
                ControlToValidate="tbxPassword"
                ValidationExpression="^[a-zA-Z0-9]{7,99}$"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RegularExpressionValidator>

            <br />
            <br />
            <asp:Label ID="lblConfirmPassword" runat="server" Text="Confirm Password:"></asp:Label>
            <br />
            <asp:TextBox ID="tbxConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>&nbsp;
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
                ErrorMessage="Confirm Password Required    "
                ControlToValidate="tbxConfirmPassword"
                Display="Dynamic"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RequiredFieldValidator>
            <asp:CompareValidator ID="CompareValidator1" runat="server"
                ErrorMessage="Passwords don't match    "
                ControlToCompare="tbxPassword"
                ControlToValidate="tbxConfirmPassword"
                Display="Dynamic"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:CompareValidator>

            <br />
            <br />
            <asp:Label ID="lblUserType" runat="server" Text="User Type:"></asp:Label>
            <br />
            <asp:DropDownList ID="ddlUserType" runat="server">
                <asp:ListItem>Reception</asp:ListItem>
                <asp:ListItem>Management</asp:ListItem>
            </asp:DropDownList>
        </div>

        <div style="margin-top: 20px; margin-bottom: 20px">
            <hr />
        </div>

        <div id="Staff">
            <asp:Label ID="lblStaffID" runat="server" Text="Staff ID:"></asp:Label>
            <br />
            <asp:TextBox ID="tbxStaffID" runat="server" ReadOnly="True"></asp:TextBox>

            <br />
            <br />
            <asp:Label ID="lblName" runat="server" Text="Name:"></asp:Label>
            <br />
            <asp:TextBox ID="tbxName" runat="server"></asp:TextBox>&nbsp;
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                ErrorMessage="Name Required    "
                Display="Dynamic"
                ControlToValidate="tbxName"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server"
                ErrorMessage="Name only allows spaces and letters    "
                Display="Dynamic"
                ControlToValidate="tbxName"
                ValidationExpression="^((\s|[a-zA-Z])+)$"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RegularExpressionValidator>

            <br />
            <br />
            <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>
            <asp:Label ID="lblDOB" runat="server" Text="Date of Birth (DOB):"></asp:Label>
            <br />
            <asp:TextBox ID="tbxDOB" runat="server"></asp:TextBox>
            <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="tbxDOB" Format="yyyy-MM-dd" SelectedDate="1990-01-01"></ajaxToolkit:CalendarExtender>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator7" runat="server" 
                ErrorMessage="RegularExpressionValidator" 
                ValidationExpression="^(19|20)\d\d([-])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$" 
                ControlToValidate="tbxDOB" 
                Text="Invalid Date Input" 
                Font-Bold="True"
                ForeColor="Red"></asp:RegularExpressionValidator>

            <br />
            <br />
            <asp:Label ID="lblBankNo" runat="server" Text="Bank No:"></asp:Label>
            <br />
            <asp:TextBox ID="tbxBankNo" runat="server"></asp:TextBox>&nbsp;
            <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
                ErrorMessage="Bank No Required    "
                ControlToValidate="tbxBankNo"
                Display="Dynamic"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server"
                ErrorMessage="Bank No must be 9 digits long and only allow numbers    "
                ControlToValidate="tbxBankNo"
                Display="Dynamic"
                ValidationExpression="^\d{9}$"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RegularExpressionValidator>

            <br />
            <br />
            <asp:Label ID="lblAddress" runat="server" Text="Address:"></asp:Label>
            <br />
            <asp:TextBox ID="tbxAddress" runat="server" TextMode="MultiLine" Style="resize: none;"></asp:TextBox>&nbsp;
            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
                ErrorMessage="Address Required    "
                Display="Dynamic"
                ControlToValidate="tbxAddress"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RequiredFieldValidator>
            <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" 
                FilterType="UppercaseLetters, LowercaseLetters, Numbers, Custom" 
                ValidChars="#-, " 
                TargetControlID="tbxAddress"></ajaxToolkit:FilteredTextBoxExtender>

            <br />
            <br />
            <asp:Label ID="lblTelNo" runat="server" Text="Tel No:"></asp:Label>
            <br />
            <asp:TextBox ID="tbxTelNo" runat="server" TextMode="Phone"></asp:TextBox>&nbsp;
            <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
                ErrorMessage="Telephone No Required    "
                Display="Dynamic"
                ControlToValidate="tbxTelNo"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server"
                ErrorMessage="Telephone No must be exactly 8 numbers long and only allow numbers    "
                Display="Dynamic"
                ControlToValidate="tbxTelNo"
                ValidationExpression="^([0-9]{8})$"
                ValidationGroup="groupUpdate"
                Font-Bold="True"
                ForeColor="Red"></asp:RegularExpressionValidator>

            <br />
            <br />
            <asp:Label ID="lblDutyType" runat="server" Text="Duty Type:"></asp:Label>
            <br />
            <asp:DropDownList ID="ddlDutyType" runat="server">
                <asp:ListItem>General</asp:ListItem>
                <asp:ListItem>Room</asp:ListItem>
                <asp:ListItem>Estate</asp:ListItem>
                <asp:ListItem>Security</asp:ListItem>
            </asp:DropDownList>
        </div>

        <div id="Button" style="margin-top: 20px; margin-bottom: 20px; margin-right: 20%; text-align: right">
            <asp:Button ID="updateBtn" runat="server" Text="Update"
                OnClick="updateBtn_Click"
                ValidationGroup="groupUpdate"
                OnClientClick="return validateAndConfirm('Are you sure you want to update?')" 
                CssClass="btnGreen"/>
        </div>
    </div>
</asp:Content>
